/**
 * @file  MiraPrint.h
 * @author Josep Sabater (jsabaterm@el.ub.edu)
 * @date   February, 2015
 * @version 1.0.0
 * @ingroup Util
 * @brief Interface for several printing operations.
 *
 *
 */
#ifndef MIRA_PRINT_H
#define MIRA_PRINT_H

#include <vector>
#include <iterator>
#include <iostream>

// Preprocessor directive to print the name of a variable.
#define VAR_NAME(var_name) #var_name

namespace MiraUtilUBLib{
   /**
    * @brief Template to print vectors.
    */
    template<typename T>
        std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) {
            /*
            out << "[";
            size_t last = v.size() - 1;
            for(size_t i = 0; i < v.size(); ++i) {
                out << v[i];
                if (i != last) 
                    out << ", ";
            }
            out << "]";
            return out;
            */
             
            if ( !v.empty() ) {
              out << '[';
              std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
              out << "\b\b]";
            }
            return out;           
        }   
}
#endif
